//
//  BaseViewController.m
//  TBRJL
//
//  Created by 程三 on 15/6/2.
//  Copyright (c) 2015年 程三. All rights reserved.
//

#import "BaseViewController.h"
#import "Globle.h"
@interface BaseViewController ()

@end

@implementation BaseViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
}




//是否显示加载提示
-(void)showLoading:(BOOL)show
{
    if(_loadView == nil)
    {
        float width = UIScreenW;
        float heigh = UIScreenH;
        int statusBarHeight = 20;
        int titleBarHeight = 44;
        
        _loadView = [[UIView alloc] initWithFrame:CGRectMake(0,0,width, heigh - statusBarHeight - titleBarHeight)];
        _loadView.backgroundColor = [UIColor whiteColor];
        
        //loadingView
        UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        activityView.frame = CGRectMake((_loadView.w - 35)/2, (_loadView.h - 35)/2, 35, 35);
        [activityView startAnimating];
        
        [_loadView addSubview:activityView];
    }
    
    if(show)
    {
        if(![_loadView superview])
        {
            //添加到TableView中
            [self.view addSubview:_loadView];
        }
    }
    else
    {
        if([_loadView superview])
        {
            //从TableView中移除
            [_loadView removeFromSuperview];
        }
    }
    
}


//显示没有数据提示
-(void)showNotice:(BOOL)show
{
    if(_noticeView == nil)
    {
        
        float width = UIScreenW;
        float heigh = UIScreenH;
        int statusBarHeight = 20;
        int titleBarHeight = 44;
        
        //加载label
        _noticeView = [[UIView alloc] initWithFrame:CGRectMake(0,0,width, heigh - statusBarHeight - titleBarHeight)];
        _noticeView.backgroundColor = [UIColor whiteColor];
        
        //加载label
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,width, heigh - statusBarHeight - titleBarHeight)];
        //label.backgroundColor = [UIColor whiteColor];
        label.text = @"没有数据";
        label.font = [UIFont systemFontOfSize:16.0];
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        [_noticeView addSubview:label];
        
    }
    
    if(show)
    {
        if(![_noticeView superview])
        {
            //添加到TableView中
            [self.view addSubview:_noticeView];
        }
    }
    else
    {
        if([_noticeView superview])
        {
            //从TableView中移除
            [_noticeView removeFromSuperview];
        }
    }
    
}

@end
